import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';

process.env = Object.assign(process.env, loadEnv('dev', process.cwd(), ''));
// console.log('PROXY_API_URL', process.env.PROXY_API_URL);
// console.log('BUILD_OUT_DIR', process.env.BUILD_OUT_DIR);

export default defineConfig({
  plugins: [vue()],
  css: { preprocessorOptions: { scss: { charset: false } } },
  build: {
    outDir: process.env.BUILD_OUT_DIR || 'dist',
    rollupOptions: {
      output: {
        entryFileNames: 'assets/[name].js',
        chunkFileNames: 'assets/[name].js',
        assetFileNames: 'assets/[name].[ext]',
      },
    },
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, '/src'),
    },
  },
  server: {
    proxy: {
      '/zb_system/api.php': process.env.PROXY_API_URL,
    },
  },
  // base:"./"
});
